from redis import StrictRedis


class Config:
    # 开启调试模式
    DEBUG = None
    # 设置密钥
    SECRET_KEY = 'QZihYxvb4y41htnXOw8OG62h2zlXuaAzF1oa28NjJV8='
    # 设置数据库连接
    SQLALCHEMY_DATABASE_URI = 'mysql://root:039758@localhost/info'
    # 关闭数据库动态追踪
    SQLALCHEMY_TRACK_MODIFICATIONS = False

    # 定义redis的主机及端口常量
    REDIS_HOST = '127.0.0.1'
    REDIS_PORT = 6379

    # 配置session信息的存储类型
    SESSION_TYPE = 'redis'
    # 配置session信息的存储位置
    SESSION_REDIS = StrictRedis(host=REDIS_HOST, port=REDIS_PORT)
    # 配置session信息开启用户标记
    SESSION_USE_SIGNER = True
    # 配置session信息的有效期为1天
    PERMANENT_SESSION_LIFETIME = 86400


class developmentConfig(Config):
    DEBUG = True


class productionConfig(Config):
    DEBUG = False


config = {
    'development': developmentConfig,
    'production': productionConfig
}
